Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hapi/ammo

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/ammo

HTTP Range processing utilities

  • 5.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
345K
decreased by-57.22%
Maintainers
1
Weekly downloads
 
Created

What is @hapi/ammo?

@hapi/ammo is a utility library for HTTP payload processing, specifically designed to handle HTTP payload ranges. It is part of the hapi ecosystem and is used to parse and validate HTTP Range headers, which are often used for partial content delivery.

What are @hapi/ammo's main functionalities?

Range Parsing

This feature allows you to parse the 'Range' HTTP header and determine the byte ranges requested by the client. The `Ammo.header` function takes the range header and the total length of the resource, returning an array of ranges.

const Ammo = require('@hapi/ammo');

const rangeHeader = 'bytes=0-4,9-15';
const length = 20;
const ranges = Ammo.header(rangeHeader, length);

console.log(ranges);

Range Validation

This feature validates the parsed ranges to ensure they are within the bounds of the resource length. If the ranges are valid, it returns an array of ranges; otherwise, it returns null.

const Ammo = require('@hapi/ammo');

const rangeHeader = 'bytes=0-4,9-15';
const length = 20;
const ranges = Ammo.header(rangeHeader, length);

if (ranges) {
  console.log('Valid ranges:', ranges);
} else {
  console.log('Invalid range header');
}

Other packages similar to @hapi/ammo

Keywords

FAQs

Package last updated on 13 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc